Skip to content

fix(workflows): disallow duplicate workflow names at the same folder level#3260

Merged
waleedlatif1 merged 1 commit intostagingfrom
fix/name
Feb 19, 2026
Merged

fix(workflows): disallow duplicate workflow names at the same folder level#3260
waleedlatif1 merged 1 commit intostagingfrom
fix/name

Conversation

@waleedlatif1
Copy link
Collaborator

Summary

  • Added duplicate name validation on workflow PUT endpoint — rejects renaming/moving a workflow if another workflow with the same name exists at the same folder nesting level (409 Conflict)
  • Only enforced on update, does not retroactively affect existing duplicates
  • Added shared testing mocks to @sim/testing: mockHybridAuth, telemetryMock, requestUtilsMock
  • Replaced inline mocks across 22 test files with shared @sim/testing utilities

Type of Change

  • Bug fix

Testing

  • 7 new test cases for duplicate name validation (same folder, root level, cross-folder, folder move, color-only update)
  • All existing tests verified passing

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link

vercel bot commented Feb 19, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Feb 19, 2026 9:57pm

Request Review

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 19, 2026

Greptile Summary

This PR adds duplicate workflow name validation at the folder level and refactors test mocks into shared utilities.

Key Changes:

  • Duplicate name validation checks workflow names within the same folder (or root level) on PUT operations
  • Returns 409 Conflict when a duplicate is detected during rename or folder move
  • Only validates when name or folderId changes; skips check for other field updates
  • Correctly handles null folderId for root-level workflows
  • Added 7 comprehensive test cases covering various duplicate scenarios
  • Extracted inline mocks into shared @sim/testing utilities: mockHybridAuth, telemetryMock, requestUtilsMock
  • Updated 22 test files to use shared mocks, improving consistency and maintainability

Implementation Quality:

  • Logic correctly distinguishes between truthy folderId values and null/root level using isNull() condition
  • Validation only runs when necessary (name/folder changes), avoiding unnecessary database queries
  • Test coverage is thorough, including edge cases like cross-folder moves and color-only updates

Confidence Score: 5/5

  • Safe to merge - well-tested bug fix with proper validation logic
  • The duplicate validation logic is sound with proper null handling, comprehensive test coverage (7 new test cases), and the mock refactoring improves test maintainability without changing behavior
  • No files require special attention

Important Files Changed

Filename Overview
apps/sim/app/api/workflows/[id]/route.ts Added duplicate name validation with proper null handling for root-level folders
apps/sim/app/api/workflows/[id]/route.test.ts 7 comprehensive test cases for duplicate validation; refactored to use shared mocks
packages/testing/src/mocks/hybrid-auth.mock.ts New shared hybrid auth mock with helper methods for test setup
packages/testing/src/mocks/telemetry.mock.ts New shared telemetry mock using Proxy for dynamic PlatformEvents
packages/testing/src/mocks/request.mock.ts Added requestUtilsMock for generateRequestId mocking

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[PUT /api/workflows/id] --> B{name or folderId updated?}
    B -->|No| C[Update workflow directly]
    B -->|Yes| D[Determine target name & folderId]
    D --> E{workspaceId exists?}
    E -->|No| F[Return 500 error]
    E -->|Yes| G[Build query conditions]
    G --> H[Check for duplicate]
    H --> I{Duplicate found?}
    I -->|Yes| J[Return 409 Conflict]
    I -->|No| C
    C --> K[Return updated workflow]
    
    subgraph "Duplicate Check Logic"
        G --> L[workspace = current]
        G --> M[name = target name]
        G --> N[id != current id]
        G --> O{targetFolderId?}
        O -->|truthy| P[folderId = targetFolderId]
        O -->|falsy/null| Q[folderId IS NULL]
    end
Loading

Last reviewed commit: 0c09526

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

28 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

@waleedlatif1 waleedlatif1 merged commit 3c470ab into staging Feb 19, 2026
12 checks passed
@waleedlatif1 waleedlatif1 deleted the fix/name branch February 19, 2026 22:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments